<?php 
use \PsiFramework\Classes\Util\UI\Printer;
use \PsiFramework\Classes\Util\UI\HTML;

$form = $response->getAttribute('form');
$entry = $response->getAttribute('entry');
$responseId = $response->getAttribute('responseId');
$part = $response->getAttribute('part');
$price = $part->getPrice();
$quantities = $response->getAttribute('quantities');
$currencySymbol = $response->getAttribute('Currency')->getSymbol();
?>
<div class="centre">
<h3><?php Printer::display($languageManager->getText('PRODUCT_ADDED_TO_BASKET')); ?> :</h3>
    <form
        action="<?php Printer::display(HTML::linkHref("action=OrderTheme&entry_id=".$entry->getId()."&form_id=".$form->getId())); ?>"
        method="POST" >
		<fieldset class="boxshadow-contenu">
			<div class="img-produit"><?php
			if (!is_null($form->getImage())) {
			?><img src="<?php Printer::display($form->getImage()->getImageLink()); ?>" alt="" />
			<?php 
			}
			?></div>
			<div class="titre"><?php Printer::display($entry . ' - ' . $form); ?></div>
				<label>
					<?php Printer::display($languageManager->getText('CHOSE_SUBSCRIPTION_LENGTH')); ?> :
				</label>
				<p>
				<?php
				$total = 0;
				$reduction = 0;
				
                foreach($quantities as $q=>$qv){
                    $displayParams = $q.', '.$price;
                    $currentTotal = $q*$price;
                    $currentDiscount = 0;
                    if($qv['discount'] != null){
                        $discount = $qv['discount'];
                        $displayParams .= ', ' . $discount->getValue();
                        if ($discount->isPercentage()) {
                            $displayParams .= ', true';
                            $currentDiscount = $currentTotal * ($discount->getValue()/100);
                        } else {
                            $displayParams .= ', false';
                            $currentDiscount .= $discount->getValue();
                        }
                        
                        $currentTotal = $currentTotal - $currentDiscount;
                    }
                    
                ?>
					<label>
					    <input
                            type="radio"
                            name="quantity"
                            onchange="javascript:updateTotal(<?php Printer::display($displayParams); ?>)"
                            value="<?php Printer::display($q); ?>"
                            <?php 
                            if ($qv['selected']) {
                                $reduction = $currentDiscount;
                                $total = $currentTotal;
                                echo 'checked="checked"' ;   
                            }
                            ?>/>
                        <?php Printer::display($qv['label']); ?>
				    </label>
				<?php
                }
                ?>
                </p>
				<div class="boxshadow-prix">
					<div id="item_discount" class="remise"><?php
                	    if (!isNullOrEmptyString($reduction) && $reduction>0) {
                	        Printer::display('(Soit '.number_format($reduction, 2, '.', ' ').$currencySymbol.' d\'économie)');
                	    }
                	?></div>
					<div id="item_total" class="prix"><?php Printer::display(number_format($total, 2, '.', ' ').$currencySymbol); ?></div>
				</div>
		</fieldset>
		<input class="btn_confirmer" type="submit" value="<?php Printer::display($languageManager->getText('CONFIRM')); ?>" />
		</a>
	</form>
</div>
<div class="haut-gauche coin"></div><div class="haut-centre"></div><div class="haut-droite coin"></div><div class="centre-gauche bord"></div><div class="centre-droite bord"></div><div class="bas-gauche coin"></div><div class="bas-centre"></div><div class="bas-droite coin"></div>
<!-- Trace -->
<?php $templateManager->displayTemplate('Trace');  ?>